<?php
/**
 * User: krisbuist
 * Date: 2/3/12
 * Time: 1:45 PM
 */
class TagSearch extends SearchResult
{
    public function __construct($em, $searchString)
    {
        parent::__construct($em);
        $this->resultQuery = $this->em->createQuery("SELECT p FROM Post p JOIN p.tags t WHERE t.name LIKE :tagName ORDER BY p.id DESC");
        $this->resultQuery->setMaxResults($this->resultsPerPage);
        $this->resultQuery->setParameter('tagName', '%' . $searchString . '%');

        $this->countQuery = $this->em->createQuery("SELECT COUNT(p) FROM Post p JOIN p.tags t WHERE t.name LIKE :tagName");
        $this->countQuery->setParameter('tagName', '%' . $searchString . '%');
    }
}
